package test_new;

import org.junit.*;

public class MatrixTest {
	@Test
	public void testRotateInPlace_OneByOneMatrix(){
		Integer[] arrayOne = new Integer[]{1};
		Matrix<Integer> matrix = new Matrix<Integer>(new Integer[][]{arrayOne});
		matrix.rotateInPlace();
		Assert.assertArrayEquals(new Integer[][]{{1}}, matrix.getArray());		
				
	}
	@Test
	public void testRotateInPlace_ThreeByThree(){
		Integer[][] arrayOne = new Integer[][]{
				{1, 2, 3}, 
				{4, 5, 6}, 
				{7, 8, 9}};
		Matrix<Integer> matrix = new Matrix<Integer>(arrayOne);
		matrix.rotateInPlace();
		Assert.assertArrayEquals(new Integer[][]{
				{7, 4, 1}, 
				{8, 5, 2}, 
				{9, 6, 3}}, matrix.getArray());	
	}
	@Test
	public void testRotateInPlace_FiveByFive(){
		Integer[][] arrayOne = new Integer[][]{
				{1,   2,  3,  4,  5}, 
				{6,   7,  8,  9, 10}, 
				{11, 12, 13, 14, 15},
				{16, 17, 18, 19, 20},
				{21, 22, 23, 24, 25}};
		Matrix<Integer> matrix = new Matrix<Integer>(arrayOne);
		matrix.rotateInPlace();
		Assert.assertArrayEquals(new Integer[][]{
				{21, 16, 11, 6, 1}, 
				{22, 17, 12, 7, 2}, 
				{23, 18, 13, 8, 3},
				{24, 19, 14, 9, 4},
				{25, 20, 15, 10, 5}}, matrix.getArray());	
	}
	@Test
	public void testTranspose_ThreeByThree(){
		Integer[][] arrayOne = new Integer[][]{
				{1, 2, 3}, 
				{4, 5, 6}, 
				{7, 8, 9}};
		Matrix<Integer> matrix = new Matrix<Integer>(arrayOne);
		matrix.transposeInPlace();
		Assert.assertArrayEquals(new Integer[][]{
				{1, 4, 7}, 
				{2, 5, 8}, 
				{3, 6, 9}}, matrix.getArray());	
	}
}
